local assets =
{
        Asset("ANIM", "anim/npc_item_cards_experience_pack.zip"),
        Asset( "IMAGE", "images/inventoryimages/npc_item_cards_experience_pack.tex" ),  -- 背包贴图
        Asset( "ATLAS", "images/inventoryimages/npc_item_cards_experience_pack.xml" ),
}

local function GetStringsTable()
    return TUNING.NPC_CHAT_TABLE[ type(TUNING.__NPC_LANGUAGE)=="function" and TUNING.__NPC_LANGUAGE() or TUNING.__NPC_LANGUAGE ] ["npc_item_cards_experience_pack"] or {}
end

local function spellfn(inst, target, pos, doer)
    if doer and doer:HasTag("npc_tag.isplayer") and doer.components.npc_cards_sys then
        doer.components.npc_cards_sys:Start()
        inst:Remove()
    end
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddSoundEmitter()
    inst.entity:AddNetwork()

    inst:AddTag("quickcast")
    --   需要 inst.components.spellcaster.quickcast = true 同步支持tag 才能快速施法，单纯加tag不行

    MakeInventoryPhysics(inst)

    inst.AnimState:SetBank("npc_item_cards_experience_pack")
    inst.AnimState:SetBuild("npc_item_cards_experience_pack")
    inst.AnimState:PlayAnimation("idle_1",true)

    MakeInventoryFloatable(inst, "med", 0.05, {0.7, 0.4, 0.7}, true, -13, {sym_build = "swap_hammer"})


    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end
    inst:AddComponent("npc_base_lib")

    inst:AddComponent("inventoryitem")
    inst.components.inventoryitem.imagename = "npc_item_cards_experience_pack"
    inst.components.inventoryitem.atlasname = "images/inventoryimages/npc_item_cards_experience_pack.xml"
    -----
    MakeHauntableLaunch(inst)
    inst:AddComponent("inspectable")
    inst:AddComponent("named")
    inst.components.named:SetName(GetStringsTable().name)
    inst.components.inspectable:SetDescription(GetStringsTable().inspect_str)

    inst:AddComponent("spellcaster")
    inst.components.spellcaster.canusefrominventory = true
    -- inst.components.spellcaster.quickcast = true
    inst.components.spellcaster:SetSpellFn(spellfn)


    return inst
end

return Prefab("npc_item_cards_experience_pack", fn, assets)
